package com.googlecode.carlosmonterocanabal.mojosprites.sprites;

import java.awt.Point;

public abstract class RectanglePacker {

    protected int PackingAreaWidth;

    protected int PackingAreaHeight;

    protected RectanglePacker(int packingAreaWidth, int packingAreaHeight) {
        PackingAreaWidth = packingAreaWidth;
        PackingAreaHeight = packingAreaHeight;
    }


    public Point Pack(int rectangleWidth, int rectangleHeight) {
        Point point = tryPack(rectangleWidth, rectangleHeight);

        if (point == null)
            throw new IllegalArgumentException("Rectangle does not fit in packing area");

        return point;
    }

    public abstract Point tryPack(int rectangleWidth, int rectangleHeight);

    public int getPackingAreaWidth() {
        return PackingAreaWidth;
    }

    public void setPackingAreaWidth(int packingAreaWidth) {
        PackingAreaWidth = packingAreaWidth;
    }

    public int getPackingAreaHeight() {
        return PackingAreaHeight;
    }

    public void setPackingAreaHeight(int packingAreaHeight) {
        PackingAreaHeight = packingAreaHeight;
    }

}
